package com.ecommerce.product.entity;

import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import javax.persistence.*;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.time.LocalDateTime;

/**
 * 商品促销信息实体类
 * 
 * @author ecommerce-team
 * @version 1.0.0
 */
@Entity
@Table(name = "product_promotion")
@TableName("product_promotion")
public class ProductPromotion {
    
    /**
     * 促销ID
     */
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;
    
    /**
     * 商品ID
     */
    @NotNull(message = "商品ID不能为空")
    @Column(name = "product_id", nullable = false)
    private Long productId;
    
    /**
     * 促销类型（如：满减、优惠券、秒杀等）
     */
    @NotBlank(message = "促销类型不能为空")
    @Column(name = "type", nullable = false, length = 20)
    private String type;
    
    /**
     * 促销文案
     */
    @NotBlank(message = "促销文案不能为空")
    @Column(name = "text", nullable = false, length = 200)
    private String text;
    
    /**
     * 促销开始时间
     */
    @Column(name = "start_time")
    private LocalDateTime startTime;
    
    /**
     * 促销结束时间
     */
    @Column(name = "end_time")
    private LocalDateTime endTime;
    
    /**
     * 促销状态：0-未开始，1-进行中，2-已结束
     */
    @Column(name = "status", columnDefinition = "tinyint default 0")
    private Integer status;
    
    /**
     * 排序权重
     */
    @Column(name = "sort_order", columnDefinition = "int default 0")
    private Integer sortOrder;
    
    /**
     * 创建时间
     */
    @TableField(fill = FieldFill.INSERT)
    @Column(name = "create_time", nullable = false, updatable = false)
    private LocalDateTime createTime;
    
    /**
     * 更新时间
     */
    @TableField(fill = FieldFill.INSERT_UPDATE)
    @Column(name = "update_time", nullable = false)
    private LocalDateTime updateTime;
    
    /**
     * 逻辑删除：0-未删除，1-已删除
     */
    @TableLogic
    @Column(name = "deleted", columnDefinition = "tinyint default 0")
    private Integer deleted;
    
    // Getter and Setter methods
    public Long getId() { return id; }
    public void setId(Long id) { this.id = id; }
    
    public Long getProductId() { return productId; }
    public void setProductId(Long productId) { this.productId = productId; }
    
    public String getType() { return type; }
    public void setType(String type) { this.type = type; }
    
    public String getText() { return text; }
    public void setText(String text) { this.text = text; }
    
    public LocalDateTime getStartTime() { return startTime; }
    public void setStartTime(LocalDateTime startTime) { this.startTime = startTime; }
    
    public LocalDateTime getEndTime() { return endTime; }
    public void setEndTime(LocalDateTime endTime) { this.endTime = endTime; }
    
    public Integer getStatus() { return status; }
    public void setStatus(Integer status) { this.status = status; }
    
    public Integer getSortOrder() { return sortOrder; }
    public void setSortOrder(Integer sortOrder) { this.sortOrder = sortOrder; }
    
    public LocalDateTime getCreateTime() { return createTime; }
    public void setCreateTime(LocalDateTime createTime) { this.createTime = createTime; }
    
    public LocalDateTime getUpdateTime() { return updateTime; }
    public void setUpdateTime(LocalDateTime updateTime) { this.updateTime = updateTime; }
    
    public Integer getDeleted() { return deleted; }
    public void setDeleted(Integer deleted) { this.deleted = deleted; }
}